perm filename NEWSCN.TMP[TEX,DEK] blob
sn#554100 filedate 1981-01-05 generic text, type T, neo UTF8
comment Accessing user's files: scanfilename, inputfile, opendigit, definefont;
comment This page contains the most operating-system dependent aspects
of the TEX input system;
internal saf string array fontname[0:nfonts-1] # user name for each font code;
IFTENEX require ifc TOPS20 thenc "TEXF20.SAI" elsec "TEXFIL.SAI" endc source_file;
ENDTENEX
IFTOPS10 require "TEXF10.SAI" source_file; ENDTOPS10
ifc (SUAI or MIT) thenc
IFSUAI
saf string array fname[0:2] # file name, extension, and directory;
simp procedure scanfilename # sets up fname[0:2];
begin integer j;
fname[0]←fname[1]←fname[2]←null;
j←0;
loop begin getnctok;
if curcmd = spacer then done;
if curcmd≥charcodes then
begin backerror("Blank space should follow file name"); done;
end;
if curchar = "." then j←1
else if curchar = "[" then j←2;
fname[j]←fname[j]&curchar;
end;
end;
ENDSUAI
IFMIT
string fnamedir, fname1, fname2;
simp procedure scanfilename # sets up file name in fnamedir, fname1, fname2;
begin
string fcomp; # file name component;
boolean firstchar, vbar;
fcomp←fnamedir←fname1←fname2←null;
firstchar←true;
vbar←false;
loop begin getnctok;
if firstchar and curcmd = spacer then done;
if curcmd≥charcodes then
begin backerror("Blank space should follow file name"); done;
end;
if curcmd = spacer then
begin
if fcomp≠null then
if fname1=null then fname1←fcomp else fname2←fcomp;
fcomp←null;
if not vbar then done
end
else if curchar = "|" then
if firstchar then vbar←true else done
else if curchar = ";" then
begin
if fcomp≠null then fnamedir←fcomp;
fcomp←null
end
else fcomp←fcomp&curchar;
firstchar←false;
end;
if fcomp≠null then
if fname1=null then fname1←fcomp else fname2←fcomp;
if fnamedir≠null then fnamedir←fnamedir&";";
if fname1=null then fname1←"@";
end;
ENDMIT
internal procedure inputfile;
begin comment "\input" has just been scanned. This procedure scans the user's
file name, employing the appropriate operating system naming conventions,
then reads in the first line and feeds it to the input system;
integer chan;
label abort # if something goes wrong trying to read the file;
label try # go here to try or try again;
string flname;
integer pageno # number of pages successfully read;
define checkeof=⊂if eof then begin print(")");go to abort end⊃;
try:
scanfilename;
IFSUAI
if fname[1]=0 then fname[1]←".TEX";
flname←fname[0]&fname[1]&fname[2];
ENDSUAI
IFMIT
if fname2=null then fname2←">";
flname←fnamedir&fname1&" "&fname2;
ENDMIT
open(chan←getchan,"DSK",0,if inptr=0 then 19 else 2, 0,
150,brchar,eof);
comment On the SAIL system, 19 buffers is the most efficient for disk files;
comment The lines read in must have at most 150 characters;
lookup(chan,flname,eof);
IFSUAI
if eof and fname[2]=0 then lookup(chan,fname[0]&fname[1]&"[1,3]",eof);
ENDSUAI
IFMIT
if eof then lookup(chan,"TEX;"&fname1&" "&fname2,eof);
ENDMIT
if eof then
begin error("Lookup failed on file "&flname);
release(chan); go to try;
end;
print(" (",flname);
pushinput # save present file status;
state←newline; recovery←chan; filename←flname;
inbuf←input(chan,crffbreak) # get first line of file;
checkeof; print(" 1");
if equ(inbuf[1 to 9],"COMMENT ⊗") then
begin comment Skip TVedit directory page;
while brchar≠'14 and not eof do inbuf←input(chan,ffbreak);
checkeof;
inbuf←input(chan,crffbreak) # get first line of second page;
checkeof; print(" 2");
pageno←2;
end
else pageno←1;
while brchar='14 do
begin comment Ignore empty pages at beginning of file;
inbuf←input(chan,crffbreak); checkeof; pageno←pageno+1; print(" ",pageno);
end;
loc ← (pageno lsh infod) + 1 # line 1 of the current page;
if tracing land '20 then
begin integer p # garbage bin;
if inbuf='12 then p←lop(inbuf);
if length(inbuf)=1 then inbuf←" "&inbuf;
print(nextline);
ifc MIT thenc outstr( elsec ptostr(0, endc
inbuf[1 to ∞-1]) # show inbuf on screen;
inbuf←inchwl&inbuf[∞ to ∞];
end;
curbuf←inbuf;
comment Now define the output file name if it hasn't yet been defined;
IFSUAI
if ofilname=0 then declareofil(fname[0]&ofilext);
ENDSUAI
IFMIT
if ofilname=0 then declareofil(fnamedir&fname1&" "&ofilext);
ENDMIT
return;
abort: release(chan);
popinput;
end;
internal integer procedure opendigit(integer d) # Do this after "\open d =";
begin integer chan; string s;
scanfilename;
IFSUAI if fname[1]=0 then fname[1]←".TEX"; s←fname[0]&fname[1]&fname[2]; ENDSUAI
IFMIT if fname2=null then fname2←">"; s←fnamedir&fname1&" "&fname2; ENDMIT
open(chan←getchan,"DSK",0,0,2,0,0,eof);
loop begin enter(chan,s,eof);
if eof then
begin print(nextline,"I can't write on file ",s,
nextline,"Output file for \open "&d&" = ");
s←inchwl;
end
else done
end;
return(chan);
end;
endc
IFTOPS10 require "The procedure definefont must be adjusted for TOPS10." message;
require "Either modify the definition in TEXF10.SAI, or add a TOPS10 case" message;
require " to the definition that follows:" message; ENDTOPS10
internal procedure definefont(integer f) # Do this after seeing "=" of font def;
begin integer n,p,chan,dwidth,digits; real psize; string s,ss;
label try # go here to try or try again;
boolean atclause # first attempt to read the file;
try: scanfilename; do getnctok until curcmd≠spacer; backinput;
atclause←scanstring("at");
if atclause then psize←scanposlength else psize←0;
getformat(dwidth,digits);
setformat(5,1);
IFSUAI
if fname[2]=0 then fname[2]←libraryarea; s←fname[0];
if length(s)>6 then s←s[1 to 3]&s[∞-2 to ∞];
ENDSUAI
IFMIT
if fnamedir=0 then fnamedir←libraryarea; s←fname1;
ENDMIT
IFTENEX
if fname[0]=0 then fname[0]←libraryarea; s←fname[1];
ENDTENEX
s←s&" at "&(if atclause then cvf(psize) else "*")&"pts"
# without directory or extension;
if fontname[f] and not equ(s,fontname[f]) then
begin error("Sorry, this font code is already defined to be "&fontname[f]);
return;
end;
fontname[f]←s;
setformat(dwidth,digits);
if parbase[f]=0 then
begin comment font information not preloaded;
open(chan←getchan,"DSK",8,2,0,0,0,eof);
IFSUAI
lookup(chan,ss←fname[0]&deviceext&fname[2],eof);
ENDSUAI
IFMIT
lookup(chan,ss←fnamedir&fname1&" "&deviceext,eof);
ENDMIT
IFTENEX
lookup(chan,ss←fname[0]&fname[1]&deviceext,eof);
ENDTENEX
if eof then
begin error("Lookup failed on file "&ss);
release(chan); go to try;
end;
readfontinfo(chan,f,psize,atclause) # input font info for use by TEXSEM and TEXOUT;
release(chan);
end;
p←fontglue+f*gluespecsize # location of "font glue";
mem[p]←1000000 lsh infod # "infinite" reference count;
gluespace(p)←fontpar(f,spacewd);
gluestretch(p)←fontpar(f,spacestr);
glueshrink(p)←fontpar(f,spaceshr);
end;
end